﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARS.Control.Custom.Entity.Interface
{
    public abstract class IChoiceDialogOtherTableModel
    {
        //存值得字段名称
        public abstract string Db_Field_Name();
        //request传值
        public abstract string RequestKey();
        //显示值
        public abstract string DataTextField();
        //value
        public abstract string DataValueField();
        //查询语句
        public virtual string QuerySql()
        {
            return string.Format("SELECT {0}.{2},{0}.{3} FROM {0},{1} where {1}.{2}={0}.{2} and {1}.{4}={{0}}", this.ValueTableName(), this.SaveTableName(), this.DataValueField(),this.DataTextField(),this.KeyField());
        }

        //插入执行的语句
        public virtual string InsertSql()
        {
            return string.Format("INSERT INTO {0}({1},{2}) VALUES({{0}},{{1}})",this.SaveTableName(),this.DataValueField(),this.KeyField());
        }

        //删除执行的操作
        public virtual string DeleteSql()
        {
            return string.Format("delete from {1} where {0}={{0}}",this.KeyField(),this.SaveTableName());
        }

        public abstract bool IsEncryptKey();
        //保存的表名
        public abstract string SaveTableName();

        /// <summary>
        /// 保存值的表
        /// </summary>
        /// <returns></returns>
        public abstract string ValueTableName();
        /// <summary>
        /// 主键
        /// </summary>
        /// <returns></returns>
        public abstract string KeyField();
        /// <summary>
        /// 保存值得字段
        /// </summary>
        /// <returns></returns>
        //public abstract string ValueField();

    }
}
